package com.airticketbooking.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author Mr.J
 * @version 1.0.0
 * @date 2024/11/11
 * @desc
 */

@Mapper
public interface OrderWithTicketMapper {


	@Select("SELECT ticket_id FROM airticketbooking.order_ticket WHERE order_id = #{orderId}")
	List<Integer> getTicketIdsByOrderId(Integer orderId);

	@Insert("INSERT INTO airticketbooking.order_ticket (order_id, ticket_id) VALUES (#{orderId}, #{ticketId})")
	void add(Integer orderId, Integer ticketId);

	@Insert("DELETE FROM airticketbooking.order_ticket WHERE order_id = #{orderId} AND ticket_id = #{oldTicketId}")
	void delete(Integer orderId, Integer oldTicketId);
}
